--
-- Author: yawei.zhu
-- Date: 2018-12-18 15:38:51
--
-- PvpChallengeRankAwardView
--
local PvpChallengeBookRender = import(".renders.PvpChallengeBookRender")

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.PvpChallengeRankAwardScene

function ClassRef:init()
	self._ui.Button_close:addClickEventListener(function()
		self:closeView()
	end)

	self._ui.tips:setString(L("challengeTips13"))
end

function ClassRef:updateView(playId)
	local challengeConf = GD:getChallengeInfo(playId)
	local rankId = tonumber(challengeConf.rankId)
	self:updateViewByRankId(rankId)
end

function ClassRef:updateViewByRankId(rankId)
	local listView = self._ui.ListView
	listView:removeAllChildren()

	local rankInfo = GD:getRankingConfigById(rankId)
	local arrItems = string.split(rankInfo.rewardShow, ";")
	-- dump(arrItems)

	local length = #arrItems
	for i = 1, length do
		local render = PvpChallengeBookRender.create()
		render:setData({index = i, data = arrItems[i]})
		listView:pushBackCustomItem(render)
	end
	listView:refreshView()

	if rankId == 1201 then
		self._ui.tips:setString(L("duelGametips40"))
	elseif rankId == Enums.TeamTarget.eliteMatchArena 
	or rankId == Enums.TeamTarget.eliteMatchDuel then
		self._ui.tips:setString(L("EliteMatchTip22"))
	else
		self._ui.tips:setString(L("challengeTips13"))
	end
end

return ClassRef
